@extends('layouts.default')

@section('title')
{{{ $lab->title }}}_@parent
@stop

@section('description')
{{{ $lab->excerpt }}}
@stop

@section('content')

<div class="col-md-9 topics-show main-col">

  <!-- Lab Detial -->
  <div class="topic panel panel-default">
    <div class="infos panel-heading">

      <div class="pull-right avatar_large">
        <a href="{{ route('users.show', $lab->user->id) }}">
          <img src="{{ $lab->user->present()->gravatar }}" style="width:65px; height:65px;" class="img-thumbnail avatar" />
        </a>
      </div>

      <h1 class="panel-title topic-title">{{{ $lab->title }}}</h1>

      @include('labs.partials.meta')
    </div>

    <div class="content-body entry-content panel-body">

      @include('labs.partials.body', array('body' => $lab->body))

      @include('labs.partials.ribbon')
    </div>

    @include('labs.partials.lab_operate')
  </div>

  <div class="panel panel-default">
    @include('labs.partials.infonav', ['current' => 'members'])
  </div>

  <div class="replies panel panel-default list-panel replies-index">
    <div class="panel-heading">
      <div class="total">{{ lang('Total Member Count') }}: <b>{{ $members->getTotal() }}</b> </div>
    </div>

    <div class="panel-heading">
        <div class="row">

          @if ($currentUser && $currentUser->id == $lab->user_id )
          <div class="col-lg-6">
           {{ Form::open(['route' => 'labs.refresh_code', 'id' => 'reply-form', 'method' => 'post']) }}
            <input type="hidden" name="lab_id" value="{{ $lab->id }}" />
            <div class="input-group">
              <span class="input-group-btn">
                {{ Form::submit($lab->invitation_code ? lang('Refresh Invitation Code') : lang('Generate Invitation Code'), ['class' => 'btn', 'id' => 'reply-create-submit']) }}
              </span>
              {{ Form::text('code', $lab->invitation_code ? : lang('Dont have any invitation code yet'), ['class' => 'form-control', 'rows' => 5, 'disabled' => 'disabled', 'placeholder' => lang('Please write down invitation code')]) }}
            </div>
            {{ Form::close() }}
          </div>
          @endif

          @if ($currentUser && $currentUser->id != $lab->user_id || !$currentUser)
          <div class="col-lg-6">
            {{ Form::open(['route' => 'labs.join', 'id' => 'reply-form', 'method' => 'post']) }}
            <input type="hidden" name="lab_id" value="{{ $lab->id }}" />
            <div class="input-group">
              {{ Form::text('invitation_code', null, ['class' => 'form-control', 'rows' => 5, 'placeholder' => lang('Please write down invitation code')]) }}
              <span class="input-group-btn">
                {{ Form::submit(lang('Join Lab'), ['class' => 'btn', 'id' => 'reply-create-submit']) }}
              </span>
            </div>
            {{ Form::close() }}
          </div>
          @endif

        </div>
    </div>

    <div class="panel-body">

      @if (count($members))
        @include('labs.partials.members')
      @else
         <div class="empty-block">{{ lang('No members') }}~~</div>
      @endif

      <!-- Pager -->
      <div class="pull-right" style="padding-right:20px">
        {{ $members->appends(Request::except('page'))->links(); }}
      </div>
    </div>
  </div>

</div>

@include('layouts.partials.sidebar')

@stop
